import time


def sorts(lst):
    index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0]
    a12234 = [0, [], 0, 0]

    for i in range(1,14):
        while i in lst:
            index[i]=index[i]+1
            lst.remove(i)

    if (max(index) == 4):
        a12234[3] = index.index(4)
        index[index.index(4)] = 0

    if(max(index)==3):

        a12234[2]=index.index(3)
        index[index.index(3)]=0

    while(max(index)==2):
        if(a12234[2]==1):
            a12234[2]=a12234[2]+13
        a12234[1].append(index.index(2))
        index[index.index(2)] = 0

    a12234[0] = 0
    for i in range(len(index)):
        if index[i]==1:
            a12234[0]=i
    return a12234
    #返回 字典duishu 【1,2,2,3,4】 单牌

def dianzhi(lst):
    lst.sort()
    if sum((lst[i + 1] - lst[i]) == 1 for i in range(4)) == 4:
        return 28 * lst[1] + 13 * 28 * 28 * 28

    else:
        a = sorts(lst)
        while (len(a[1]) != 2):
            a[1].append(0)

        a = [a[0], a[1][0], a[1][1], a[2], a[3]]
        a.reverse()
        zhi = 0
        for i in a:
            zhi = zhi * 28 + i
        return zhi



def qiuzhi(zong):
    index_huase = [0, 0, 0, 0, 0]
    lst = [i[1] for i in zong]
    for i in zong:
        index_huase[i[0]] = index_huase[i[0]] + 1

    if max(index_huase) == 5:
        return 28 * 28 * max(lst) + 13 * 28 * 28 * 28

    else:
        return dianzhi(lst)


def zuidazhi(temp):   #输入7个

    dading=[]
    a=[i for i in range(7)]
    for i in range(7):
        a.pop(i)
        for j in range(i+1,7):
            a.pop(j-1)
            a23=qiuzhi([temp[k] for k in a])
            dading.append(a23)
#            if a23<30000:
 #               print(a,a23,[temp[k] for k in a])
            a.insert(j-1,j)
        a.insert(i,i)
    return max(dading)


def  zongpai(temp):   #temp就是进场

    yifupai = []
    for i in range(1, 14):
        for j in range(4):
            yifupai.append([j, i])

    a=temp[0:3]  #给定
    b=temp[3:5]  #我的底牌
    potential=[]
    for i in yifupai:
        if i not in temp:
            potential.append(i)
    all1=[]

    potential1 = potential.copy()
    for i in range(len(potential)):
        a1=potential1.pop(i)

        for j in range(i+1,len(potential)):    ###每种底牌


            dp=[potential[i],potential[j]]
            z=zuidazhi(temp+dp)
            f.write(str(z))
            f.write("\n")
            f.write(str(temp+dp))
            f.write("\n")
            b1=potential1.pop(j-1)
            zhiyu=[z]

            for k in range(len(potential1)):
                for l in range(k + 1, len(potential1)):     ###每种对方的排

                    zhiyu.append(zuidazhi(a+dp+[potential1[k],potential1[l]]))

            zhiyu.sort()

            acc=zhiyu.index(z)/len(zhiyu)

            zhiyu.reverse()
            acc=acc/2+(1-zhiyu.index(z)/len(zhiyu))/2
            f.write(str(zhiyu))
            f.write("\n")
            all1.append(acc)
            potential1.insert(j-1,b1)
        potential1.insert(i,a1)
    print (sum(all1)/len(all1))

def trans(n):
    if n ==1:
        return 13
    else:
        return n-1



#[a,b,c,d,e,f]=map(int,input("请输入三张公共牌的花色与点数:(花色为0,1,2,3 黑桃 方片 红桃 梅花)，点数为1~13：\n").split())
#temp=[[a,b],[c,d],[e,f]]
#(a,b,c,d)=map(int,input("请输入两张底牌牌的花色与点数:(花色为0,1,2,3 黑桃 方片 红桃 梅花)，点数为1~13：\n").split())
#temp.append([a,b],[c,d])

#for i in temp:
 #   i[1]=trans(i[1])

a=time.time()
f=open("test.txt","w")
zongpai([[1,9],[0,8],[2,5],[1,10],[1,12]])

f.close()

print(time.time()-a)





